//
//  WKTopTableViewCell.m
//  WKDemo
//
//  Created by wjm on 14-8-4.
//  Copyright (c) 2014年 com.app. All rights reserved.
//

#import "WKTopTableViewCell.h"
#import "WKTopTableViewCellFrame.h"
#import "WKResult.h"
#import "UIImageView+WebCache.h"
#import "WKCellToolbar.h"

@interface WKTopTableViewCell ()
//用户头像
@property (nonatomic,weak)UIImageView *userIcon;
//用户名字
@property (nonatomic,weak)UILabel *userName;
//发表时间
@property (nonatomic,weak)UILabel *userSendtime;
//段子正文
@property (nonatomic,weak)UILabel *userText;
//段子工具条
@property (nonatomic,weak)WKCellToolbar *userTool;
@end

@implementation WKTopTableViewCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        // 用户头像
        UIImageView *userIcon = [[UIImageView alloc]init];
        [self addSubview:userIcon];
        self.userIcon = userIcon;
        
        // 用户姓名
        UILabel *userName = [[UILabel alloc]init];
        userName.font  = [UIFont systemFontOfSize:12];
        [self addSubview:userName];
        self.userName = userName;
        
        // 发送时间
        UILabel *userSendtime = [[UILabel alloc]init];
        userSendtime.font = [UIFont systemFontOfSize:10];
        userSendtime.textColor = [UIColor orangeColor];
        [self addSubview:userSendtime];
        self.userSendtime = userSendtime;
        
        // 段子正文
        UILabel *userText = [[UILabel alloc]init];
        userText.font = [UIFont systemFontOfSize:14];
        userText.numberOfLines = 0;
        userText.textColor = [UIColor blackColor];
       // userText.backgroundColor = [UIColor purpleColor];
        [self addSubview:userText];
        self.userText = userText;
        
//        //底部工具条
//        WKCellToolbar *userTool = [[WKCellToolbar alloc]init];
//        [self addSubview:userText];
//        self.userTool.backgroundColor = [UIColor redColor];
//        self.userTool = userTool;
        
        
    }
    self.backgroundColor = [UIColor whiteColor];
    return self;
}

- (void)setTopFrame:(WKTopTableViewCellFrame *)TopFrame
{
    _TopFrame = TopFrame;
    
    self.frame = TopFrame.frame;
    
    WKResult *restlt = TopFrame.Topreqsult;
    
    //添加用户图片
//    UIColor *color1 = [UIColor black75PercentColor];
//    UIColor *color2 = [UIColor watermelonColor];
    
    UIImageView *img = [[UIImageView alloc]init];
    [img setImageWithURL:[NSURL URLWithString:restlt.profile_image] placeholderImage:[UIImage imageNamed:@"placeholderImage1"]];
    
    
//    [self.userIcon setImageWithURL:[NSURL URLWithString:restlt.profile_image] placeholderImage:[UIImage imageNamed:@"shoppingNavigationButtonRefreshClick"]];
    
    self.userIcon.image = [UIImage circleImageWithName:img.image borderWidth:1 borderColor:[UIColor black75PercentColor]];

    self.userIcon.frame = TopFrame.userIconFrame;
    
    //添加用户姓名
    self.userName.text = restlt.name;
    self.userName.frame = TopFrame.userNameFrame;
    
    //添加发送时间
    self.userSendtime.text = restlt.passtime;
    self.userSendtime.frame = TopFrame.userSendTimeFrame;
    
    //添加正文
    self.userText.text = restlt.text;
    self.userText.frame = TopFrame.userTextFrame;
    
    //添加工具条
    //self.userTool.frame = TopFrame.userBootFrame;
    
}
@end
